﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Threading;
using System.Threading;
using LockCrypt.Core;

namespace LockCrypt {
    /// <summary>
    /// Logs messages to a BackgroundWorker.
    /// </summary>
    public class BackgroundWorkerLogger : ILogProvider {
        private BackgroundWorker worker;

        public BackgroundWorkerLogger(BackgroundWorker worker) {
            if(!worker.WorkerReportsProgress)
                worker.WorkerReportsProgress = true;
            this.worker = worker;
        }
        public void Log(string message) {
            worker.ReportProgress(0, message);
        }

        public void Log(string message, bool isError) {
            worker.ReportProgress(0, new StatusMessage(message, isError ? StatusMessage.StatusMessageType.Error : StatusMessage.StatusMessageType.Status));
        }

        public void Log(string message, StatusMessage.StatusMessageType messageType) {
            worker.ReportProgress(0, message);
        }

        public void Log(StatusMessage message) {
            worker.ReportProgress(0, message);
        }
    }
}
